package com.jy.wms.controller;
import com.jy.wms.webservice.*;
/*
import com.jy.wms.webservice.CountryRepository;
*/
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;

import javax.annotation.Resource;

@Endpoint
public class CountryEndpoint {
    private static final String NAMESPACE_URI = "http://www.yourcompany.com/webservice";
    @Resource
    CountryRepository countryRepository;
    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "getCountryRequest")
    @ResponsePayload
    public GetCountryResponse getCountry(@RequestPayload GetCountryRequest request) {
        GetCountryResponse response = new GetCountryResponse();
        Country poland = new Country();
        poland.setName("Poland-" + request.getPlanId());
        poland.setCapital("Warsaw");
        poland.setCurrency(Currency.PLN);
        poland.setPopulation(38186860);
        response.setResult(countryRepository.findCountry(request.getPlanId(),request.getPlanNO(),request.getGoodsnumber(),request.getLocationName(),request.getPlanNum(),request.getInventoryNum(),request.getDifferenceState()));

        return response;
    }
}